# Maintainer: Sven-Hendrik Haase <svenstaro@archlinux.org>
# Maintainer: Caleb Maclennan <caleb@alerque.com>
# Contributor: Wesley Moore <wes@wezm.net>
# Contributor: Cosmic Horror <CosmicHorrorDev@pm.me>

pkgname=sd
pkgver=1.0.0
pkgrel=1
pkgdesc='Intuitive find & replace'
arch=('loong64' 'x86_64')
url="https://github.com/chmln/sd"
license=('MIT')
depends=('gcc-libs')
makedepends=('rust')
source=("$pkgname-$pkgver.tar.gz::https://github.com/chmln/sd/archive/v${pkgver}.tar.gz")
sha256sums=('2adc1dec0d2c63cbffa94204b212926f2735a59753494fca72c3cfe4001d472f')

build() {
  cd "$pkgname-$pkgver"

  cargo build --release --locked
}

check() {
  cd "$pkgname-$pkgver"
  cargo test --release --locked
}

package() {
  install -Dm755 "$pkgname-$pkgver/target/release/$pkgname" "$pkgdir/usr/bin/$pkgname"
  install -Dm644 "$pkgname-$pkgver/LICENSE" "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
  install -Dm644 "$pkgname-$pkgver/gen/sd.1" "$pkgdir/usr/share/man/man1/sd.1"
  install -Dm644 "$pkgname-$pkgver/gen/completions/sd.bash" "$pkgdir/usr/share/bash-completion/completions/sd"
  install -Dm644 "$pkgname-$pkgver/gen/completions/_sd" "$pkgdir/usr/share/zsh/site-functions/_sd"
  install -Dm644 "$pkgname-$pkgver/gen/completions/sd.fish" "$pkgdir/usr/share/fish/vendor_completions.d/sd.fish"
  install -Dm644 "$pkgname-$pkgver/gen/completions/sd.elv" "$pkgdir/usr/share/elvish/lib/sd.elv"
}
